class Person{
    username:string;
    age:number;

    constructor(username:string,age:number){
        this.username = username;
        this.age = age;
    }

    getInfo():string{
        return `${this.username},${this.age}`
    }

    setName(username:string):void{
        this.username = username;
    }
}

let p1 = new Person('zs',18);

console.log(p1.getInfo());

console.log(p1.username);

//继承

class Student extends Person{
    constructor(username:string,age:number){
        super(username,age)
    }
    learn():void{
        console.log(`${this.age}开始学习`)
        console.log(this.username)
    }
}

let s1 = new Student('lili',10);

console.log(s1.getInfo());

//访问修饰符

//public:公共的（默认）  在自己类内和子级类内  类外可以访问 

//protected :受保护的  在自己类内和子级类内可以访问 类外不可以访问

//private:  只能在自己的类内访问，子类和类外都不能访问

